import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { TableColumn } from '@/types/table'

// 表单校验
export const rules = reactive({
  address: [{ required: true, message: '服务器不能为空', trigger: 'blur' }],
  port: [{ required: true, message: '端口不能为空', trigger: 'blur' }],
  // codedFormat: [{ required: true, message: '编码不能为空', trigger: 'blur' }],
  mode: [{ required: true, message: '请选择模式', trigger: 'change' }],


})
const modeOpt=[
  {
    value:'TLS加密',label:'TLS加密'
  },
  {
    value:'SSL加密',label:'SSL加密'
  }
]
// CrudSchema：https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
  {
    label: '主机',
    field: 'address',
    isSearch: false,
    form: {
      componentProps: {
        maxlength:'40',
      }
    }
  },
  // {
  //   label: '端口号',
  //   field: 'port',
  //   isSearch: false,
  // },
  // {
  //   label: ' ',
  //   field: 'encryMode',
  //   formatter: (_: Recordable, __: TableColumn, cellValue: number|string) => {
  //     return modeOpt.find((account) => account.value === cellValue)?.label
  //   },
  //   form: {
  //       component: 'Radio',
  //       value:'TLS加密',
  //       componentProps: {
  //           options: modeOpt
  //       }
  //   }
  // },
  {
    label: '用户名',
    field: 'account',
    isSearch: false,
    isTable:false,

  },
  {
    label: '密码',
    field: 'password',
    isSearch: false,
    isTable:false,

  },
 
  // {
  //   label: '发件名称',
  //   field: 'codedFormat',
  //   isTable:false,
  // },
  // {
  //   label: '  ',
  //   field: 'bcc',
  //   isTable:false,
  // },
  {
    label: '启用',
    field: 'isValid',
    dictType: DICT_TYPE.SYSTEM_MAIL_SEND_STATUS,
    isForm:false,
    isDetail: false,
  },
  {
    label: '操作',
    field: 'action',
    isDetail: false,
    isForm:false
  }
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
